//////////////////////////////////////////////////////////////////////////////////
//
//	DoD Death Fade
//		- Version 1.0
//		- 06.28.2008
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
// 	- Screen will fade when you die.. but semi-transparent..
//
// CVARS: 
//
//	dod_deathfade "1"  //(1)ON or (0)OFF
//
//	dod_deathfade_alpha "225"  //Fade alpha level
//
//	dod_deathfade_red "225"  //Fade red level
//	dod_deathfade_green "0"  //Fade green level
//	dod_deathfade_blue "0"  //Fade blue level
//
// Changelog:
//
//	 - 05.01.2006 Version 0.1
//		Initial Release
//
//	 - 05.06.2006 Version 0.2
//		Changed from MSG_ONE to MSG_ONE_UNRELIABLE
//
//	 - 05.30.2006 Version 0.3
//		Adjusted ScreenFade message variables
//
//	 - 06.02.2006 Version 0.4
//		Added CVARs to control fade RGB & alpha levels
//
//	 - 06.28.2008 Version 1.0
//		Minor code improvement
//		Moved get_user_msgid to plugin_init
//
//////////////////////////////////////////////////////////////////////////////////


#include <amxmodx>
#include <dodx>

#define VERSION "1.0"
#define SVERSION "v1.0 - by diamond-optic (www.AvaMods.com)"

new DeathFade
new p_dod_deathfade, p_dod_deathfade_alpha, p_dod_deathfade_red, p_dod_deathfade_green, p_dod_deathfade_blue

public plugin_init()
{
	register_plugin("DoD Death Fade",VERSION,"AMXX DoD Team")
	register_cvar("dod_death_fade_stats",SVERSION,FCVAR_SERVER|FCVAR_SPONLY)
	
	p_dod_deathfade = register_cvar("dod_deathfade","1")
	
	p_dod_deathfade_alpha = register_cvar("dod_deathfade_alpha","225")
	
	p_dod_deathfade_red = register_cvar("dod_deathfade_red","225")
	p_dod_deathfade_green = register_cvar("dod_deathfade_green","0")
	p_dod_deathfade_blue = register_cvar("dod_deathfade_blue","0")
	
	DeathFade = get_user_msgid("ScreenFade")
}

public client_death(killer,victim,wpnindex,hitplace,TK)
{	
	if(get_pcvar_num(p_dod_deathfade) && !is_user_alive(victim) && is_user_connected(victim) && !is_user_bot(victim))
		{
		message_begin(MSG_ONE_UNRELIABLE,DeathFade,{0,0,0},victim)
		write_short(~0) //12000
		write_short(8000) //7500
		write_short(0x0002)
		write_byte(get_pcvar_num(p_dod_deathfade_red)) //225
		write_byte(get_pcvar_num(p_dod_deathfade_green)) //0
		write_byte(get_pcvar_num(p_dod_deathfade_blue)) //0
		write_byte(get_pcvar_num(p_dod_deathfade_alpha)) //225
		message_end()
		}
}